//
//  LKOpenShopInforDataViewController.m
//  Mideleague_Agent
//
//  Created by Zhiwang on 2020/6/11.
//  Copyright © 2020 Zhiwang. All rights reserved.
//

#import "LKOpenShopInforDataViewController.h"
#import "LKUFPictureRow.h"
#import "LKUFPictureRowCell.h"
#import "LKUFOpenShopHeaderRow.h"
#import "LKUFOpenShopHeaderRowCell.h"
#import "LKUFOpenShopBottomButtonRow.h"
#import "LKUFOpenShopBottomButtonRowCell.h"
#import "LKOpenShopStepOneViewController.h"
#import "LKRateSettingViewController.h"
@interface LKOpenShopInforDataViewController ()

@property(nonatomic,strong)UFFormView *formview;
@property(nonatomic,strong)UFSection *headerSection;
@property(nonatomic,strong)UFSection *secondHeaderSection;
@property(nonatomic,strong)UFSection *thirdHeaderSection;
@property(nonatomic,strong)UFSection *FourthHeaderSection;
@property(nonatomic,strong)UFSection *FiveHeaderSection;
@property(nonatomic,copy)NSString *hadSetting;
@end

@implementation LKOpenShopInforDataViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = @"商户资料";
    self.hadSetting = @"";
    [self setNavgationRightBtn];
    [self getDetailInformationAccoringUid:self.uid];
    
    [self createFormView];

//    [self setNavgationRightBtn];
//    [self getDetailInformationAccoringUid:self.uid];
    // Do any additional setup after loading the view.
}
-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [self getDetailInformationAccoringUid:self.uid];
    [self createFormView];
}

/// 创建表单的view
-(void)setNavgationRightBtn{
    WS(weakSelf)
    LKBaseButton *rightBtn = [LKBaseButton buttonWithFrame:CGRectMake(0, 0, 64, 24) type:UIButtonTypeCustom title:@"编辑" titleColor:COLOR_HEX(0x333333) layercorne:13 font:[UIFont fontWithName:@"PingFangSC-Regular" size: 16] backgroudColor:[UIColor clearColor] AndActionBlock:^(UIButton * _Nonnull btn) {
        LKOpenShopStepOneViewController *vc = [[LKOpenShopStepOneViewController alloc] init];
        vc.uid = weakSelf.inforModel.uid;
        vc.inforModel = weakSelf.inforModel;
        [weakSelf.navigationController pushViewController:vc animated:YES];
    }];
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:rightBtn];
}

-(void)createFormView{
    WS(weakSelf)
    self.formview = [UFFormView makeFormView:^(UFFormViewMaker * _Nonnull make) {
        make
        .registerRow([LKUFOpenShopHeaderRow class], [LKUFOpenShopHeaderRowCell class])
        .registerRow([LKUFPictureRow class], [LKUFPictureRowCell class])
        .registerRow([LKUFOpenShopBottomButtonRow class], [LKUFOpenShopBottomButtonRowCell class])
        .addSection([UFSection makeSection:^(UFSectionMaker * _Nonnull make) {
            make
            .titleStyle([UFRowTitleStyle makeTitleStyle:^(UFRowTitleStyleMaker * _Nonnull make) {
               make
                .width(WIDTH/3 + 50)
                .font([UIFont fontWithName:@"PingFangSC-Regular" size:16])
                .color(labelBlackColor)
                .textAlignment(NSTextAlignmentLeft);
            }])
            .valueStyle([UFTextStyle makeTextStyle:^(UFRowTextStyleMaker * _Nonnull make) {
                make
                .textAlignment(NSTextAlignmentRight)
                .font([UIFont fontWithName:@"PingFangSC-Regular" size:16])
                .color(labelBlackColor);
            }])
            .addRow([UFTextFieldRow makeTextFieldRow:^(UFTextFieldRowMaker * _Nonnull make) {
                make
                .editable(NO)
                .height(RowHeightDefault)
                .title(@"商户费率")
                .value(weakSelf.hadSetting)
                .name(@"e_mail")
                .rowDidSelected(^(__kindof UFRow * _Nonnull row) {
                    LKRateSettingViewController *vc = [[LKRateSettingViewController alloc] init];
                    vc.inforModel = weakSelf.inforModel;
                    vc.modelBlock = ^(LKMyShopOpenInforModel * _Nullable model) {
                        weakSelf.inforModel = model;
                        weakSelf.hadSetting = @"已设置";
                        [weakSelf.formview removeFromSuperview];
                        [weakSelf createFormView];
                        
                    };
                    [weakSelf.navigationController pushViewController:vc animated:YES];
                })
                .accessoryType(UFRowAccessoryDisclosureIndicator);
            }]);
        }])
        .addToSuperView(self.view);
    }];
    [self addFirstSectionHeader];
    [self.formview addSection:self.headerSection];
    [self addSecondSectionHeader];
    [self.formview addSection:self.secondHeaderSection];
    [self addThirdSectionHeader];
    [self.formview addSection:self.thirdHeaderSection];
    [self addFourthHeaderSection];

        if (self.showBottomBtn) {
            [self.formview mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.right.equalTo(self.view);
                make.top.equalTo(self.view.mas_top).offset(NAVIGATION_BAR_HEIGHT);
                make.bottom.equalTo(self.view).offset(-50);
            }];
            UIView *bottomView = [[UIView alloc] initWithFrame:CGRectZero];
            [self.view addSubview:bottomView];
            [bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.right.bottom.equalTo(self.view);
                make.height.mas_equalTo(50);
            }];
            LKBaseButton *agreeBtn = [LKBaseButton buttonWithFrame:CGRectMake(0, 0, WIDTH/2, 50) type:UIButtonTypeCustom title:@"校验不通过" titleColor:[UIColor whiteColor] layercorne:0 font:[UIFont fontWithName:@"PingFangSC-Regular" size:20] backgroudColor:[UIColor redColor] AndActionBlock:^(UIButton * _Nonnull btn) {
                weakSelf.inforModel.status = @"4";
                UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"请填写校验不通过理由" message:@"" preferredStyle:UIAlertControllerStyleAlert];
                [alert addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) {
            
                }];
                [alert addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
            
                }]];
                [alert addAction:[UIAlertAction actionWithTitle:@"确认" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
                    UITextField *contentTf = alert.textFields.firstObject;
                    weakSelf.inforModel.msg = contentTf.text;
                    NSDictionary *param = [weakSelf.inforModel properties_aps];
                    [[LKNetDataManager defaultManager] sendRequestMethod:HTTPMethodPOST serverUrl:ServerlUrl apiPath:MyShopOpenInformationEditUrl header:[LKUserInforTool account].token parameters:param progress:^(NSProgress * _Nullable progress) {
                        
                    } success:^(BOOL isSuccess, id  _Nullable responseObject) {
                       [SVProgressHUD showInfoWithStatus:responseObject[@"msg"]];
                        
                    } failure:^(NSString * _Nullable errorMessage) {
                        
                    }];
                }]];
                [self presentViewController:alert animated:YES completion:nil];
            }];
            [bottomView addSubview:agreeBtn];
            LKBaseButton *refuseBtn = [LKBaseButton buttonWithFrame:CGRectMake(WIDTH/2, 0, WIDTH/2, 50) type:UIButtonTypeCustom title:@"校验通过" titleColor:[UIColor whiteColor] layercorne:0 font:[UIFont fontWithName:@"PingFangSC-Regular" size:20] backgroudColor:[UIColor greenColor] AndActionBlock:^(UIButton * _Nonnull btn) {
                weakSelf.inforModel.status = @"0";
                NSDictionary *param = [weakSelf.inforModel properties_aps];
                [[LKNetDataManager defaultManager] sendRequestMethod:HTTPMethodPOST serverUrl:ServerlUrl apiPath:MyShopOpenInformationEditUrl header:[LKUserInforTool account].token parameters:param progress:^(NSProgress * _Nullable progress) {
                    
                } success:^(BOOL isSuccess, id  _Nullable responseObject) {
                   [SVProgressHUD showInfoWithStatus:responseObject[@"msg"]];
                    
                } failure:^(NSString * _Nullable errorMessage) {
                    
                }];
            }];
            [bottomView addSubview:refuseBtn];
            [self.view bringSubviewToFront:bottomView];
        }else{
            [self.formview mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.right.equalTo(self.view);
                make.top.equalTo(self.view.mas_top).offset(NAVIGATION_BAR_HEIGHT);
                make.bottom.equalTo(self.view);
            }];
        }
}

/// 添加基本信息部分页面
-(void)addFirstSectionHeader{
    WS(weakSelf)
    if ([self.inforModel.mcc_jc_id isEqualToString:@"3"]) {

        self.headerSection = [UFSection makeSection:^(UFSectionMaker * _Nonnull make) {
            make
            .titleStyle([UFRowTitleStyle makeTitleStyle:^(UFRowTitleStyleMaker * _Nonnull make) {
               make
                .width(WIDTH/3 + 50)
                .font([UIFont fontWithName:@"PingFangSC-Regular" size:16])
                .color(labelBlackColor)
                .textAlignment(NSTextAlignmentLeft);
            }])
            .valueStyle([UFTextStyle makeTextStyle:^(UFRowTextStyleMaker * _Nonnull make) {
                make
                .textAlignment(NSTextAlignmentRight)
                .font([UIFont fontWithName:@"PingFangSC-Regular" size:16])
                .color(labelBlackColor);
            }])
            .headerStyle([UFSectionStyle makeSectionStyle:^(UFSectionStyleMaker * _Nonnull make) {
                 make
                 .height(50)                         // 设置头高度
                 .text(@"基础信息")                      // 设置头描述信息
                .textAlignment(NSTextAlignmentCenter)
                 .color(COLOR_HEX(0x333333))    // 设置头描述信息颜色
                 .font([UIFont fontWithName:@"PingFangSC-Regular" size:16]); // 设置头描述信息字体
             }])
            .addRow([UFTextFieldRow makeTextFieldRow:^(UFTextFieldRowMaker * _Nonnull make) {
                make
              .editable(NO)
            .placeholder(@"")
                .placeholder(@"")
                .height(RowHeightDefault)
                .title(@"商户ID")
                .name(@"推荐人电话")
                .value(weakSelf.inforModel.uid);
            }])

            .addRow([UFTextFieldRow makeTextFieldRow:^(UFTextFieldRowMaker * _Nonnull make) {
                make
              .editable(NO)
            .placeholder(@"")
                .placeholder(@"")
                .height(RowHeightDefault)
                .title(@"推荐人电话")
                .name(@"推荐人电话")
                .value([LKUserInforTool account].user_phone);
            }])
            .addRow([UFTextFieldRow makeTextFieldRow:^(UFTextFieldRowMaker * _Nonnull make) {
                make
                            .editable(NO)
            .placeholder(@"")
                .placeholder(@"")
                .placeholder(@"请选择")
                .title(@"商户类型")
                .name(@"mcc_jc_id")
                .value([NSString backShopTypeAccordingType:self.inforModel.mcc_jc_id])
                .height(RowHeightDefault);
            }])
            .addRow([UFTextFieldRow makeTextFieldRow:^(UFTextFieldRowMaker * _Nonnull make) {
                make
                            .editable(NO)
            .placeholder(@"")
                .placeholder(@"")
                .title(@"行业类型")
                .name(@"行业类型")
                .value(weakSelf.inforModel.industry_name)
                .height(RowHeightDefault);
            }])
            .addRow([UFTextFieldRow makeTextFieldRow:^(UFTextFieldRowMaker * _Nonnull make) {
                make
                            .editable(NO)
            .placeholder(@"")
                .title(@"售卖商品/提供服务")
                .value(weakSelf.inforModel.service_description)
                .height(RowHeightDefault);
            }])
            .addRow([UFTextFieldRow makeTextFieldRow:^(UFTextFieldRowMaker * _Nonnull make) {
                make
                            .editable(NO)
            .placeholder(@"")
                .height(RowHeightDefault)
                .title(@"客服电话")
                .name(@"kefu_phone")
                .value(self.inforModel.kefu_phone);
            }])
            .addRow([UFTextFieldRow makeTextFieldRow:^(UFTextFieldRowMaker * _Nonnull make) {
                make
                            .editable(NO)
            .placeholder(@"")
                .height(RowHeightDefault)
                .title(@"邮箱")
                .name(@"e_mail")
                .value(self.inforModel.e_mail);
            }])
            .addRowWithBlock(^__kindof UFRow * _Nonnull{
                LKUFPictureRow *pictureRow = [[LKUFPictureRow alloc] init];
                pictureRow.pictureNumbers = 4;
                pictureRow.headerTitle = @"店铺照片";
                pictureRow.titlesPlaceArray = @[@"+门头照",@"+收银台照",@"+内景照",@"+外景照"];
                if (self.inforModel.header_interior_img == nil) {

                }else{
                 pictureRow.picturesArray = [[NSMutableArray alloc] initWithArray:@[self.inforModel.header_interior_img,self.inforModel.cashier_img,self.inforModel.interior_img,self.inforModel.abroad_img]];
                }

                pictureRow.height = 250;
                return pictureRow;
            });
        }];
    }else{
        self.headerSection = [UFSection makeSection:^(UFSectionMaker * _Nonnull make) {
            make
            .titleStyle([UFRowTitleStyle makeTitleStyle:^(UFRowTitleStyleMaker * _Nonnull make) {
               make
                .width(WIDTH/3 + 50)
                .font([UIFont fontWithName:@"PingFangSC-Regular" size:16])
                .color(labelBlackColor)
                .textAlignment(NSTextAlignmentLeft);
            }])
            .valueStyle([UFTextStyle makeTextStyle:^(UFRowTextStyleMaker * _Nonnull make) {
                make
                .textAlignment(NSTextAlignmentRight)
                .font([UIFont fontWithName:@"PingFangSC-Regular" size:16])
                .color(labelBlackColor);
            }])
            .headerStyle([UFSectionStyle makeSectionStyle:^(UFSectionStyleMaker * _Nonnull make) {
                 make
                 .height(50)                         // 设置头高度
                 .text(@"基础信息")                      // 设置头描述信息
                .textAlignment(NSTextAlignmentCenter)
                 .color(COLOR_HEX(0x333333))    // 设置头描述信息颜色
                 .font([UIFont fontWithName:@"PingFangSC-Regular" size:16]); // 设置头描述信息字体
             }])
            .addRow([UFTextFieldRow makeTextFieldRow:^(UFTextFieldRowMaker * _Nonnull make) {
                make
              .editable(NO)
            .placeholder(@"")
                .placeholder(@"")
                .height(RowHeightDefault)
                .title(@"商户ID")
                .name(@"推荐人电话")
                .value(weakSelf.inforModel.uid);
            }])
            .addRow([UFTextFieldRow makeTextFieldRow:^(UFTextFieldRowMaker * _Nonnull make) {
                make
                            .editable(NO)
            .placeholder(@"")
                .height(RowHeightDefault)
                .title(@"推荐人电话")
                .name(@"推荐人电话")
                .value([LKUserInforTool account].user_phone);
            }])
            .addRow([UFTextFieldRow makeTextFieldRow:^(UFTextFieldRowMaker * _Nonnull make) {
                make
                            .editable(NO)
            .placeholder(@"")
                .placeholder(@"请选择")
                .title(@"商户类型")
                .name(@"mcc_jc_id")
                .value([NSString backShopTypeAccordingType:self.inforModel.mcc_jc_id])
                .height(RowHeightDefault);
            }])
            .addRow([UFTextFieldRow makeTextFieldRow:^(UFTextFieldRowMaker * _Nonnull make) {
                make
                            .editable(NO)
            .placeholder(@"")
                .title(@"行业类型")
                .name(@"行业类型")
                .value(weakSelf.inforModel.industry_name)
                .height(RowHeightDefault);
            }])

            .addRow([UFTextFieldRow makeTextFieldRow:^(UFTextFieldRowMaker * _Nonnull make) {
                make
                            .editable(NO)
            .placeholder(@"")
                .height(RowHeightDefault)
                .title(@"客服电话")
                .name(@"kefu_phone")
                .value(self.inforModel.kefu_phone);
            }])
            .addRow([UFTextFieldRow makeTextFieldRow:^(UFTextFieldRowMaker * _Nonnull make) {
                make
                            .editable(NO)
            .placeholder(@"")
                .height(RowHeightDefault)
                .title(@"邮箱")
                .name(@"e_mail")
                .value(self.inforModel.e_mail);
            }])
            .addRowWithBlock(^__kindof UFRow * _Nonnull{
                LKUFPictureRow *pictureRow = [[LKUFPictureRow alloc] init];
                pictureRow.pictureNumbers = 4;
                pictureRow.headerTitle = @"店铺照片";
                pictureRow.titlesPlaceArray = @[@"+门头照",@"+收银台照",@"+内景照",@"+外景照"];
                if (self.inforModel.header_interior_img == nil) {

                }else{
                 pictureRow.picturesArray = [[NSMutableArray alloc] initWithArray:@[self.inforModel.header_interior_img,self.inforModel.cashier_img,self.inforModel.interior_img,self.inforModel.abroad_img]];
                }

                pictureRow.height = 250;
                return pictureRow;
            });
        }];

    }

}

/// 添加店铺信息部分
-(void)addSecondSectionHeader{
    WS(weakSelf)
    if ([self.inforModel.mcc_jc_id isEqualToString:@"-1"]) {
        self.secondHeaderSection = [UFSection makeSection:^(UFSectionMaker * _Nonnull make) {
            make
            .titleStyle([UFRowTitleStyle makeTitleStyle:^(UFRowTitleStyleMaker * _Nonnull make) {
               make
                .width(WIDTH/3 + 50)
                .font([UIFont fontWithName:@"PingFangSC-Regular" size:16])
                .color(labelBlackColor)
                .textAlignment(NSTextAlignmentLeft);
            }])
            .valueStyle([UFTextStyle makeTextStyle:^(UFRowTextStyleMaker * _Nonnull make) {
                make
                .textAlignment(NSTextAlignmentRight)
                .font([UIFont fontWithName:@"PingFangSC-Regular" size:16])
                .color(labelBlackColor);
            }])
            .headerStyle([UFSectionStyle makeSectionStyle:^(UFSectionStyleMaker * _Nonnull make) {
                 make
                 .height(50)                         // 设置头高度
                 .text(@"店铺信息")                      // 设置头描述信息
                .textAlignment(NSTextAlignmentCenter)
                 .color(COLOR_HEX(0x333333))    // 设置头描述信息颜色
                 .font([UIFont fontWithName:@"PingFangSC-Regular" size:16]); // 设置头描述信息字体
             }])
            .addRow([UFTextFieldRow makeTextFieldRow:^(UFTextFieldRowMaker * _Nonnull make) {
                make
                .maxLength(20)
            .editable(NO)
            .placeholder(@"")
                .height(RowHeightDefault)
                .title(@"商户名称")
                .value(weakSelf.inforModel.merchant_name);
            }])
            .addRow([UFTextFieldRow makeTextFieldRow:^(UFTextFieldRowMaker * _Nonnull make) {
                make
                .maxLength(12)
                            .editable(NO)
            .placeholder(@"")
                .placeholder(@"请选择")
                .title(@"商户简称")
                .value(weakSelf.inforModel.merchant_jiancheng)
                .height(RowHeightDefault);
            }])
            .addRow([UFTextFieldRow makeTextFieldRow:^(UFTextFieldRowMaker * _Nonnull make) {
                make
                            .editable(NO)
            .placeholder(@"")
                .title(@"店铺类型")
                .name(@"店铺类型")
                .value([weakSelf.inforModel.store_type isEqualToString:@"0"] ? @"总店":@"单门店")
                .height(RowHeightDefault);
            }])
            .addRow([UFTextFieldRow makeTextFieldRow:^(UFTextFieldRowMaker * _Nonnull make) {
                make
                            .editable(NO)
            .placeholder(@"")
                .title(@"店铺地址")
                .value([NSString stringWithFormat:@"%@%@%@%@",weakSelf.inforModel.province,weakSelf.inforModel.city,weakSelf.inforModel.county,weakSelf.inforModel.address])
                .height(RowHeightDefault);
            }])
            .addRowWithBlock(^__kindof UFRow * _Nonnull{
                LKUFPictureRow *pictureRow = [[LKUFPictureRow alloc] init];
                pictureRow.pictureNumbers = 2;
                pictureRow.headerTitle = @"收单服务协议（选传，用于专属通道）";
                pictureRow.titlesPlaceArray = @[@"+收单服务协议",@"+收单服务协议"];
                pictureRow.picturesArray = [[NSMutableArray alloc] initWithArray:@[weakSelf.inforModel.receipt_img_one,weakSelf.inforModel.receipt_img_two]];
                pictureRow.height = 145;
                return pictureRow;
            });
        }];
    }else if ([self.inforModel.mcc_jc_id isEqualToString:@"3"]){
        self.secondHeaderSection = [UFSection makeSection:^(UFSectionMaker * _Nonnull make) {
            make
            .titleStyle([UFRowTitleStyle makeTitleStyle:^(UFRowTitleStyleMaker * _Nonnull make) {
               make
                .width(WIDTH/3 + 50)
                .font([UIFont fontWithName:@"PingFangSC-Regular" size:16])
                .color(labelBlackColor)
                .textAlignment(NSTextAlignmentLeft);
            }])
            .valueStyle([UFTextStyle makeTextStyle:^(UFRowTextStyleMaker * _Nonnull make) {
                make
                .textAlignment(NSTextAlignmentRight)
                .font([UIFont fontWithName:@"PingFangSC-Regular" size:16])
                .color(labelBlackColor);
            }])
            .headerStyle([UFSectionStyle makeSectionStyle:^(UFSectionStyleMaker * _Nonnull make) {
                 make
                 .height(50)                         // 设置头高度
                 .text(@"店铺信息")                      // 设置头描述信息
                .textAlignment(NSTextAlignmentCenter)
                 .color(COLOR_HEX(0x333333))    // 设置头描述信息颜色
                 .font([UIFont fontWithName:@"PingFangSC-Regular" size:16]); // 设置头描述信息字体
             }])
            .addRow([UFTextFieldRow makeTextFieldRow:^(UFTextFieldRowMaker * _Nonnull make) {
                make
                                .maxLength(20)
                            .editable(NO)
            .placeholder(@"")
                .height(RowHeightDefault)
                .title(@"商户名称")
                .value(weakSelf.inforModel.merchant_name);
            }])
            .addRow([UFTextFieldRow makeTextFieldRow:^(UFTextFieldRowMaker * _Nonnull make) {
                make
                                .maxLength(12)
                            .editable(NO)
            .placeholder(@"")
                .placeholder(@"请选择")
                .title(@"商户简称")
                .value(weakSelf.inforModel.merchant_jiancheng)
                .height(RowHeightDefault);
            }])
            .addRow([UFTextFieldRow makeTextFieldRow:^(UFTextFieldRowMaker * _Nonnull make) {
                make
                            .editable(NO)
            .placeholder(@"")
                .title(@"店铺类型")
                .name(@"店铺类型")
                .value([weakSelf.inforModel.store_type isEqualToString:@"0"] ? @"总店":@"单门店")
                .height(RowHeightDefault);
            }])
            .addRow([UFTextFieldRow makeTextFieldRow:^(UFTextFieldRowMaker * _Nonnull make) {
                make
                            .editable(NO)
            .placeholder(@"")
                .title(@"店铺地址")
                .value([NSString stringWithFormat:@"%@%@%@%@",weakSelf.inforModel.province,weakSelf.inforModel.city,weakSelf.inforModel.county,weakSelf.inforModel.address])
                .height(RowHeightDefault);
            }]);
        }];
    }else{
        self.secondHeaderSection = [UFSection makeSection:^(UFSectionMaker * _Nonnull make) {
            make
            .titleStyle([UFRowTitleStyle makeTitleStyle:^(UFRowTitleStyleMaker * _Nonnull make) {
               make
                .width(WIDTH/3 + 50)
                .font([UIFont fontWithName:@"PingFangSC-Regular" size:16])
                .color(labelBlackColor)
                .textAlignment(NSTextAlignmentLeft);
            }])
            .valueStyle([UFTextStyle makeTextStyle:^(UFRowTextStyleMaker * _Nonnull make) {
                make
                .textAlignment(NSTextAlignmentRight)
                .font([UIFont fontWithName:@"PingFangSC-Regular" size:16])
                .color(labelBlackColor);
            }])
            .headerStyle([UFSectionStyle makeSectionStyle:^(UFSectionStyleMaker * _Nonnull make) {
                 make
                 .height(50)                         // 设置头高度
                 .text(@"店铺信息")                      // 设置头描述信息
                .textAlignment(NSTextAlignmentCenter)
                 .color(COLOR_HEX(0x333333))    // 设置头描述信息颜色
                 .font([UIFont fontWithName:@"PingFangSC-Regular" size:16]); // 设置头描述信息字体
             }])
            .addRow([UFTextFieldRow makeTextFieldRow:^(UFTextFieldRowMaker * _Nonnull make) {
                make
                                .maxLength(20)
                            .editable(NO)
            .placeholder(@"")
                .height(RowHeightDefault)
                .title(@"商户名称")
                .value(weakSelf.inforModel.merchant_name);
            }])
            .addRow([UFTextFieldRow makeTextFieldRow:^(UFTextFieldRowMaker * _Nonnull make) {
                make
                                .maxLength(12)
                            .editable(NO)
            .placeholder(@"")
                .placeholder(@"请选择")
                .title(@"商户简称")
                .value(weakSelf.inforModel.merchant_jiancheng)
                .height(RowHeightDefault);
            }])
            .addRow([UFTextFieldRow makeTextFieldRow:^(UFTextFieldRowMaker * _Nonnull make) {
                make
                            .editable(NO)
            .placeholder(@"")
                .title(@"店铺类型")
                .name(@"店铺类型")
                .value([weakSelf.inforModel.store_type isEqualToString:@"0"] ? @"总店":@"单门店")
                .height(RowHeightDefault);
            }])
            .addRow([UFTextFieldRow makeTextFieldRow:^(UFTextFieldRowMaker * _Nonnull make) {
                make
                            .editable(NO)
            .placeholder(@"")
                .title(@"店铺地址")
                .value([NSString stringWithFormat:@"%@%@%@%@",weakSelf.inforModel.province,weakSelf.inforModel.city,weakSelf.inforModel.county,weakSelf.inforModel.address])
                .height(RowHeightDefault);
            }])
            .addRow([UFTextFieldRow makeTextFieldRow:^(UFTextFieldRowMaker * _Nonnull make) {
                make
                            .editable(NO)
            .placeholder(@"")
                .height(RowHeightDefault)
                .title(@"营业执照号")
                .value(self.inforModel.business_license_number);
            }])
            .addRowWithBlock(^__kindof UFRow * _Nonnull{
                LKUFPictureRow *pictureRow = [[LKUFPictureRow alloc] init];
                pictureRow.pictureNumbers = 1;
                pictureRow.headerTitle = @"营业执照照片";
                if (weakSelf.inforModel.business_license) {
                    pictureRow.picturesArray = [[NSMutableArray alloc] initWithArray:@[weakSelf.inforModel.business_license]];
                }else{

                }

                pictureRow.height = 145;
                return pictureRow;
            })
            .addRowWithBlock(^__kindof UFRow * _Nonnull{
                LKUFPictureRow *pictureRow = [[LKUFPictureRow alloc] init];
                pictureRow.pictureNumbers = 2;
                pictureRow.headerTitle = @"收单服务协议（选传，用于专属通道）";
                pictureRow.titlesPlaceArray = @[@"+收单服务协议",@"+收单服务协议"];
                if (weakSelf.inforModel.receipt_img_one) {
                    pictureRow.picturesArray = [[NSMutableArray alloc] initWithArray:@[weakSelf.inforModel.receipt_img_one,weakSelf.inforModel.receipt_img_two]];
                }

                pictureRow.height = 145;
                return pictureRow;
            });
        }];
    }

}

/// 添加法人信息部分
-(void)addThirdSectionHeader{
    WS(weakSelf)
    self.thirdHeaderSection = [UFSection makeSection:^(UFSectionMaker * _Nonnull make) {
        make
        .titleStyle([UFRowTitleStyle makeTitleStyle:^(UFRowTitleStyleMaker * _Nonnull make) {
           make
            .width(WIDTH/3 + 50)
            .font([UIFont fontWithName:@"PingFangSC-Regular" size:16])
            .color(labelBlackColor)
            .textAlignment(NSTextAlignmentLeft);
        }])
        .valueStyle([UFTextStyle makeTextStyle:^(UFRowTextStyleMaker * _Nonnull make) {
            make
            .textAlignment(NSTextAlignmentRight)
            .font([UIFont fontWithName:@"PingFangSC-Regular" size:16])
            .color(labelBlackColor);
        }])
        .headerStyle([UFSectionStyle makeSectionStyle:^(UFSectionStyleMaker * _Nonnull make) {
             make
             .height(50)                         // 设置头高度
             .text(@"法人信息")                      // 设置头描述信息
            .textAlignment(NSTextAlignmentCenter)
             .color(COLOR_HEX(0x333333))    // 设置头描述信息颜色
             .font([UIFont fontWithName:@"PingFangSC-Regular" size:16]); // 设置头描述信息字体
         }])
        .addRowWithBlock(^__kindof UFRow * _Nonnull{
            LKUFPictureRow *pictureRow = [[LKUFPictureRow alloc] init];
            pictureRow.pictureNumbers = 3;
            pictureRow.headerTitle = @"二代身份证照片(请上传法人的身份证照)";
            pictureRow.titlesPlaceArray = @[@"+身份证正面照",@"+身份证背面照",@"+手持身份证正面照"];
            if (weakSelf.inforModel.positive_id_card_img) {
            pictureRow.picturesArray = [[NSMutableArray alloc] initWithArray:@[weakSelf.inforModel.positive_id_card_img,weakSelf.inforModel.id_card_img,weakSelf.inforModel.hand_id_card_img]];
            }
            pictureRow.height = 250;
            return pictureRow;
        })
        .addRow([UFTextFieldRow makeTextFieldRow:^(UFTextFieldRowMaker * _Nonnull make) {
            make
                        .editable(NO)
            .placeholder(@"")
            .height(RowHeightDefault)
            .title(@"姓名")
            .name(@"推荐人电话")
            .value(weakSelf.inforModel.account_name);
        }])
        .addRow([UFTextFieldRow makeTextFieldRow:^(UFTextFieldRowMaker * _Nonnull make) {
            make
                        .editable(NO)
            .placeholder(@"")
            .placeholder(@"请选择")
            .title(@"身份证号码")
            .name(@"mcc_jc_id")
            .value(weakSelf.inforModel.id_number)
            .height(RowHeightDefault);
        }])
        .addRow([UFTextFieldRow makeTextFieldRow:^(UFTextFieldRowMaker * _Nonnull make) {
            make
            .title(@"证件开始日期")
            .name(@"ID_endTime")
            .value([NSString stringWithFormat:@"%@",[NSString timestampSwitchTime:[weakSelf.inforModel.id_number_start_time integerValue] andFormatter:@"YYYY-MM-dd"]]);
        }])
        .addRow([UFTextFieldRow makeTextFieldRow:^(UFTextFieldRowMaker * _Nonnull make) {
            make
            .title(@"证件结束日期")
            .name(@"ID_endTime")
            .value([NSString stringWithFormat:@"%@",[NSString timestampSwitchTime:[weakSelf.inforModel.id_number_end_time integerValue] andFormatter:@"YYYY-MM-dd"]]);
        }]);

    }];
}

/// 添加收款信息第四部分
-(void)addFourthHeaderSection{
    if ([self.inforModel.mcc_jc_id isEqualToString:@"-1"]) {
        if ([self.inforModel.account_type isEqualToString:@"1"]) {
//            [self createFarenFormView];
            [self getFarenHeaderSection];
            [self.formview addSection:self.FourthHeaderSection];
        }
        if ([self.inforModel.account_type isEqualToString:@"2"]) {
            [self getFarenHeaderSection];
            [self.formview addSection:self.FourthHeaderSection];
            [self getUniFarenHeaderSection];
            [self.formview addSection:self.FiveHeaderSection];
//            [self createUnFarenFormView];
        }
    }else if ([self.inforModel.mcc_jc_id isEqualToString:@"1"] || [self.inforModel.mcc_jc_id isEqualToString:@"2"]){
        if ([self.inforModel.account_type isEqualToString:@"1"]) {
//            [self createFarenFormView];
            [self getFarenHeaderSection];
            [self.formview addSection:self.FourthHeaderSection];
        }
        if ([self.inforModel.account_type isEqualToString:@"2"]) {
//            [self createUnFarenFormView];
            [self getFarenHeaderSection];
            [self.formview addSection:self.FourthHeaderSection];
            [self getUniFarenHeaderSection];
            [self.formview addSection:self.FiveHeaderSection];
        }
        if ([self.inforModel.account_type isEqualToString:@"3"]) {
//            [self createDuiGongFormView];
            [self getDuiGongHeaderSection];
            [self.formview addSection:self.FourthHeaderSection];
        }
    }else if ([self.inforModel.mcc_jc_id isEqualToString:@"3"]){

//        [self createXiaoVFormView];
        [self getFarenHeaderSection];
        [self.formview addSection:self.FourthHeaderSection];
    }

}

/// 获取法人的部分
-(void)getFarenHeaderSection{
    WS(weakSelf)
    self.FourthHeaderSection = [UFSection makeSection:^(UFSectionMaker * _Nonnull make) {
        make
        .titleStyle([UFRowTitleStyle makeTitleStyle:^(UFRowTitleStyleMaker * _Nonnull make) {
           make
            .font([UIFont fontWithName:@"PingFangSC-Regular" size:16])
            .color(labelBlackColor)
            .textAlignment(NSTextAlignmentLeft);
        }])
        .valueStyle([UFTextStyle makeTextStyle:^(UFRowTextStyleMaker * _Nonnull make) {
            make
            .textAlignment(NSTextAlignmentRight)
            .font([UIFont fontWithName:@"PingFangSC-Regular" size:16])
            .color(labelBlackColor);
        }])
        .headerStyle([UFSectionStyle makeSectionStyle:^(UFSectionStyleMaker * _Nonnull make) {
             make
             .height(50)                         // 设置头高度
             .text(@"收款信息")                      // 设置头描述信息
            .textAlignment(NSTextAlignmentCenter)
             .color(COLOR_HEX(0x333333))    // 设置头描述信息颜色
             .font([UIFont fontWithName:@"PingFangSC-Regular" size:16]); // 设置头描述信息字体
         }])
        .addRow([UFTextFieldRow makeTextFieldRow:^(UFTextFieldRowMaker * _Nonnull make) {
            make
                        .editable(NO)
            .placeholder(@"")
            .height(RowHeightDefault)
            .title(@"账户类型")
            .name(@"账户类型")
            .value([NSString backTitleAccordingAccountType:weakSelf.inforModel.account_type])
            .height(RowHeightDefault);
        }])
        .addRowWithBlock(^__kindof UFRow * _Nonnull{
            LKUFPictureRow *pictureRow = [[LKUFPictureRow alloc] init];
            pictureRow.pictureNumbers = 2;
            pictureRow.headerTitle = @"银行卡照片";
            pictureRow.titlesPlaceArray = @[@"银行卡正面照片",@"银行卡背面照片"];
            pictureRow.picturesArray = [[NSMutableArray alloc] initWithArray:@[weakSelf.inforModel.positive_bank_card_img,weakSelf.inforModel.bank_card_img]];
            pictureRow.height = 145;
            return pictureRow;
        })
        .addRow([UFTextFieldRow makeTextFieldRow:^(UFTextFieldRowMaker * _Nonnull make) {
            make
                        .editable(NO)
            .placeholder(@"")
            .height(RowHeightDefault)
            .title(@"开户人")
            .valueDidChanged(^(__kindof UFRow * _Nonnull row, NSString * _Nonnull value) {
                weakSelf.inforModel.account_name = value;
            })
            .value(weakSelf.inforModel.account_name);
        }])
        .addRow([UFTextFieldRow makeTextFieldRow:^(UFTextFieldRowMaker * _Nonnull make) {
            make
                        .editable(NO)
            .placeholder(@"")
            .placeholder(@"")
              .title(@"开户银行")
              .value(weakSelf.inforModel.bank_account)
            .height(RowHeightDefault);
        }])

        .addRow([UFTextFieldRow makeTextFieldRow:^(UFTextFieldRowMaker * _Nonnull make) {
            make
                        .editable(NO)
            .placeholder(@"")
            .title(@"开户省市")
            .name(@"address")
            .value([NSString stringWithFormat:@"%@%@",weakSelf.inforModel.province_area,weakSelf.inforModel.city_area]);
        }])
        .addRow([UFTextFieldRow makeTextFieldRow:^(UFTextFieldRowMaker * _Nonnull make) {
            make
                        .editable(NO)
            .placeholder(@"")
              .title(@"开户支行")
              .name(@"开户支行")
              .value(weakSelf.inforModel.branch_account)
              .height(RowHeightDefault)
              .accessoryType(UFRowAccessoryDisclosureIndicator);
        }])
        .addRow([UFTextFieldRow makeTextFieldRow:^(UFTextFieldRowMaker * _Nonnull make) {
            make
                        .editable(NO)
            .placeholder(@"")
            .height(RowHeightDefault)
            .title(@"银行卡号")
            .name(@"银行卡号")
            .valueDidChanged(^(__kindof UFRow * _Nonnull row, NSString * _Nonnull value) {
                weakSelf.inforModel.bank_account_no = value;
            })
            .value(weakSelf.inforModel.bank_account_no);
        }])
        .addRow([UFTextFieldRow makeTextFieldRow:^(UFTextFieldRowMaker * _Nonnull make) {
            make
                        .editable(NO)
            .placeholder(@"")
            .height(RowHeightDefault)
            .title(@"预留手机号")
            .name(@"预留手机号")
            .valueDidChanged(^(__kindof UFRow * _Nonnull row, NSString * _Nonnull value) {
                weakSelf.inforModel.opening_phone = value;
            })
            .value(weakSelf.inforModel.opening_phone);
        }]);
    }];
}

/// 获取非法人的部分信息
-(void)getUniFarenHeaderSection{
    WS(weakSelf)
     self.FiveHeaderSection = ([UFSection makeSection:^(UFSectionMaker * _Nonnull make) {
        make
        .titleStyle([UFRowTitleStyle makeTitleStyle:^(UFRowTitleStyleMaker * _Nonnull make) {
           make
            .font([UIFont fontWithName:@"PingFangSC-Regular" size:16])
            .color(labelBlackColor)
            .textAlignment(NSTextAlignmentLeft);
        }])
        .valueStyle([UFTextStyle makeTextStyle:^(UFRowTextStyleMaker * _Nonnull make) {
            make
            .textAlignment(NSTextAlignmentRight)
            .font([UIFont fontWithName:@"PingFangSC-Regular" size:16])
            .color(labelBlackColor);
        }])
         .headerStyle([UFSectionStyle makeSectionStyle:^(UFSectionStyleMaker * _Nonnull make) {
              make
              .height(50)                         // 设置头高度
              .text(@"非法人信息")                      // 设置头描述信息
             .textAlignment(NSTextAlignmentCenter)
              .color(COLOR_HEX(0x333333))    // 设置头描述信息颜色
              .font([UIFont fontWithName:@"PingFangSC-Regular" size:16]); // 设置头描述信息字体
          }])
         .addRow([UFTextFieldRow makeTextFieldRow:^(UFTextFieldRowMaker * _Nonnull make) {
             make
                         .editable(NO)
            .placeholder(@"")
             .height(RowHeightDefault)
             .title(@"账户类型")
             .name(@"账户类型")
             .value([NSString backTitleAccordingAccountType:weakSelf.inforModel.account_type])
             .height(RowHeightDefault);
         }])
        .addRowWithBlock(^__kindof UFRow * _Nonnull{
            LKUFPictureRow *pictureRow = [[LKUFPictureRow alloc] init];
            pictureRow.pictureNumbers = 3;
            pictureRow.headerTitle = @"二代身份证照片(请上传非法人的身份证照)";
            pictureRow.titlesPlaceArray = @[@"+身份证正面照",@"+身份证背面照",@"+手持身份证正面照"];
            pictureRow.picturesArray = [[NSMutableArray alloc] initWithArray:@[weakSelf.inforModel.uni_positive_id_card_img,weakSelf.inforModel.uni_id_card_img,weakSelf.inforModel.hand_uni_id_card_img]];
            pictureRow.height = 250;
            return pictureRow;
        })
        .addRow([UFTextFieldRow makeTextFieldRow:^(UFTextFieldRowMaker * _Nonnull make) {
            make
                        .editable(NO)
            .placeholder(@"")
            .height(RowHeightDefault)
            .title(@"姓名")
            .name(@"姓名")
            .value(weakSelf.inforModel.uni_name);
        }])
        .addRow([UFTextFieldRow makeTextFieldRow:^(UFTextFieldRowMaker * _Nonnull make) {
            make
            .height(RowHeightDefault)
            .title(@"身份证号码")
            .name(@"身份证号码")
            .valueDidChanged(^(__kindof UFRow * _Nonnull row, NSString * _Nonnull value) {
                weakSelf.inforModel.uni_id_number = value;
            })
            .value(weakSelf.inforModel.uni_id_number);
        }])
         .addRow([UFTextFieldRow makeTextFieldRow:^(UFTextFieldRowMaker * _Nonnull make) {
             make
             .height(RowHeightDefault)
             .title(@"证件开始日期")
             .name(@"ID_startTime")
             .value([NSString stringWithFormat:@"%@",[NSString timestampSwitchTime:[self.inforModel.uni_id_number_start_time integerValue] andFormatter:@"YYYY-MM-dd"]]);
         }])
         .addRow([UFTextFieldRow makeTextFieldRow:^(UFTextFieldRowMaker * _Nonnull make) {
             make
             .height(RowHeightDefault)
             .title(@"证件结束日期")
             .name(@"ID_endTime")
             .value([NSString stringWithFormat:@"%@",[NSString timestampSwitchTime:[self.inforModel.uni_id_number_end_time integerValue] andFormatter:@"YYYY-MM-dd"]]);
         }]);

     }]);
}

/// 获取对公的部分消息
-(void)getDuiGongHeaderSection{
    WS(weakSelf)
    self.FourthHeaderSection = [UFSection makeSection:^(UFSectionMaker * _Nonnull make) {
        make
        .titleStyle([UFRowTitleStyle makeTitleStyle:^(UFRowTitleStyleMaker * _Nonnull make) {
           make
            .font([UIFont fontWithName:@"PingFangSC-Regular" size:16])
            .color(labelBlackColor)
            .textAlignment(NSTextAlignmentLeft);
        }])
        .valueStyle([UFTextStyle makeTextStyle:^(UFRowTextStyleMaker * _Nonnull make) {
            make
            .textAlignment(NSTextAlignmentRight)
            .font([UIFont fontWithName:@"PingFangSC-Regular" size:16])
            .color(labelBlackColor);
        }])
        .headerStyle([UFSectionStyle makeSectionStyle:^(UFSectionStyleMaker * _Nonnull make) {
             make
             .height(50)                         // 设置头高度
             .text(@"收款信息")                      // 设置头描述信息
            .textAlignment(NSTextAlignmentCenter)
             .color(COLOR_HEX(0x333333))    // 设置头描述信息颜色
             .font([UIFont fontWithName:@"PingFangSC-Regular" size:16]); // 设置头描述信息字体
         }])
        .addRow([UFTextFieldRow makeTextFieldRow:^(UFTextFieldRowMaker * _Nonnull make) {
            make
                        .editable(NO)
            .placeholder(@"")
            .height(RowHeightDefault)
            .title(@"账户类型")
            .name(@"账户类型")
            .value([NSString backTitleAccordingAccountType:weakSelf.inforModel.account_type])
            .height(RowHeightDefault);
        }])
        .addRowWithBlock(^__kindof UFRow * _Nonnull{
            LKUFPictureRow *pictureRow = [[LKUFPictureRow alloc] init];
            pictureRow.pictureNumbers = 1;
            pictureRow.headerTitle = @" 开户许可证（无开户许可证请上传印鉴卡）";
            pictureRow.titlesPlaceArray = @[@"开户许可证"];
            pictureRow.height = 145;
            pictureRow.picturesArray = [[NSMutableArray alloc] initWithArray:@[self.inforModel.opening_permit]];
            return pictureRow;
        })
        .addRow([UFTextFieldRow makeTextFieldRow:^(UFTextFieldRowMaker * _Nonnull make) {
            make
            .placeholder(@"")
            .editable(NO)
            .placeholder(@"")
            .height(RowHeightDefault)
            .title(@"开户人")
            .value(weakSelf.inforModel.account_name);
        }])
        .addRow([UFTextFieldRow makeTextFieldRow:^(UFTextFieldRowMaker * _Nonnull make) {
            make
                        .editable(NO)
            .placeholder(@"")
             .placeholder(@"")
              .title(@"开户银行")
              .value(weakSelf.inforModel.bank_account)
            .height(RowHeightDefault);
        }])

        .addRow([UFTextFieldRow makeTextFieldRow:^(UFTextFieldRowMaker * _Nonnull make) {
            make
            .placeholder(@"")
                        .editable(NO)
            .placeholder(@"")
            .title(@"开户省市")
            .name(@"address")
            .value([NSString stringWithFormat:@"%@%@",weakSelf.inforModel.province_area,weakSelf.inforModel.city_area]);
        }])
        .addRow([UFTextFieldRow makeTextFieldRow:^(UFTextFieldRowMaker * _Nonnull make) {
            make
                        .editable(NO)
            .placeholder(@"")
            .placeholder(@"")
              .title(@"开户支行")
              .name(@"开户支行")
              .value(weakSelf.inforModel.branch_account)
              .height(RowHeightDefault)
              .accessoryType(UFRowAccessoryDisclosureIndicator);
        }])
        .addRow([UFTextFieldRow makeTextFieldRow:^(UFTextFieldRowMaker * _Nonnull make) {
            make
                        .editable(NO)
            .placeholder(@"")
            .height(RowHeightDefault)
            .title(@"银行卡号")
            .name(@"银行卡号")
            .valueDidChanged(^(__kindof UFRow * _Nonnull row, NSString * _Nonnull value) {
                weakSelf.inforModel.bank_account_no = value;
            })
            .value(weakSelf.inforModel.bank_account_no);
        }])
        .addRow([UFTextFieldRow makeTextFieldRow:^(UFTextFieldRowMaker * _Nonnull make) {
            make
                        .editable(NO)
            .placeholder(@"")
            .height(RowHeightDefault)
            .title(@"预留手机号")
            .name(@"预留手机号")
            .valueDidChanged(^(__kindof UFRow * _Nonnull row, NSString * _Nonnull value) {
                weakSelf.inforModel.opening_phone = value;
            })
            .value(weakSelf.inforModel.opening_phone);
        }]);
    }];
}





/// 根据uid返回详细信息
/// @param uid 商户ID
-(void)getDetailInformationAccoringUid:(NSString *)uid{
    if (uid) {
        [SVProgressHUD show];
        NSDictionary *param = @{@"uid":uid};
        [[LKNetDataManager defaultManager] sendRequestMethod:HTTPMethodPOST serverUrl:ServerlUrl apiPath:MyShopOpenDetailInforUrl header:[LKUserInforTool account].token parameters:param progress:^(NSProgress * _Nullable progress) {
            
        } success:^(BOOL isSuccess, id  _Nullable responseObject) {
            [SVProgressHUD dismiss];
            if ([responseObject[@"code"] isEqualToString:@"success"]) {
                self.inforModel = [LKMyShopOpenInforModel modelWithDictionary:responseObject[@"data"]];
                if (![NSString isBlankString:self.inforModel.wx_rate]) {
                    self.hadSetting = @"已设置";
                }
                [self createFormView];
//                if ([self.inforModel.mcc_jc_id isEqualToString:@"3"]) {
//                }else{
//                    [self createFormView];
//                }
            }else{
                [SVProgressHUD showInfoWithStatus:responseObject[@"msg"]];
            }
        } failure:^(NSString * _Nullable errorMessage) {
            
        }];
    }
    
}














/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
